package com.tevintao.marketingsystem.tool;

import android.content.Context;
import android.view.WindowManager;

import com.tevintao.marketingsystem.commen.CommenApplication;

import java.lang.reflect.Field;

/**
 * Created by tevintao on 2015/12/24.
 */
public class SystemTool {

    public static int getSystemNotifycationBarHeight() {
        int mStateHeight = 0;
        Class<?> c = null;
        Object obj = null;
        Field field = null;
        int x = 0;
        try {
            c = Class.forName("com.android.internal.R$dimen");
            obj = c.newInstance();
            field = c.getField("status_bar_height");
            x = Integer.parseInt(field.get(obj).toString());
            mStateHeight = CommenApplication.getApplication().getResources().getDimensionPixelSize(x);
        } catch (Exception e1) {
            e1.printStackTrace();
        }
        return mStateHeight;
    }

    public static int getScreenWidth() {
        WindowManager wm = (WindowManager) CommenApplication.getApplication().getSystemService(Context.WINDOW_SERVICE);
        return wm.getDefaultDisplay().getWidth();
    }

    public static int getScreenHeight() {
        WindowManager wm = (WindowManager) CommenApplication.getApplication().getSystemService(Context.WINDOW_SERVICE);
        return wm.getDefaultDisplay().getHeight();
    }
}
